__author__ = 'vincent LIU'

import glob
import sys
import os
import re
import time
import rarfile

output_path = "z:\\data\\DFW\\level2\\"
bak_path = "D:\\data\\bak\DFW\\level2\\"
# speicify path for unrar.exe
rarfile.UNRAR_TOOL = "D:\\git\\lib\\UnRAR.exe"
#passwrod
pwd = "www.licai668.cn"


def Unrar_Data(market_type, curdate):
    '''
    market_type:sh/sz
    '''
    fname = bak_path + curdate + "\\" + market_type + "_" + curdate + ".rar"
    out_path = output_path + curdate + "\\" + market_type
    if os.path.exists(out_path) == False:
        os.makedirs(out_path)
    rarfd = rarfile.RarFile(fname)
    rarfd.extractall(path=out_path)


def Unrar_Level2(curdate):
    Unrar_Data("sh", curdate)
    Unrar_Data("sz", curdate)


if __name__ == "__main__":
    Unrar_Data("sh", "20150819")